package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WarehouseStore;
import com.ruoyi.system.service.IWarehouseStoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓库店铺关联信息Controller
 * 
 * @author zhl
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/system/warehouse_store")
public class WarehouseStoreController extends BaseController
{
    @Autowired
    private IWarehouseStoreService warehouseStoreService;

    /**
     * 查询仓库店铺关联信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse_store:list')")
    @GetMapping("/list")
    public TableDataInfo list(WarehouseStore warehouseStore)
    {
        startPage();
        List<WarehouseStore> list = warehouseStoreService.selectWarehouseStoreList(warehouseStore);
        return getDataTable(list);
    }

    /**
     * 导出仓库店铺关联信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse_store:export')")
    @Log(title = "仓库店铺关联信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WarehouseStore warehouseStore)
    {
        List<WarehouseStore> list = warehouseStoreService.selectWarehouseStoreList(warehouseStore);
        ExcelUtil<WarehouseStore> util = new ExcelUtil<WarehouseStore>(WarehouseStore.class);
        util.exportExcel(response, list, "仓库店铺关联信息数据");
    }

    /**
     * 获取仓库店铺关联信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse_store:query')")
    @GetMapping(value = "/{warehouseStoreId}")
    public AjaxResult getInfo(@PathVariable("warehouseStoreId") Long warehouseStoreId)
    {
        return success(warehouseStoreService.selectWarehouseStoreByWarehouseStoreId(warehouseStoreId));
    }

    /**
     * 新增仓库店铺关联信息
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse_store:add')")
    @Log(title = "仓库店铺关联信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WarehouseStore warehouseStore)
    {
        return toAjax(warehouseStoreService.insertWarehouseStore(warehouseStore));
    }

    /**
     * 修改仓库店铺关联信息
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse_store:edit')")
    @Log(title = "仓库店铺关联信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WarehouseStore warehouseStore)
    {
        return toAjax(warehouseStoreService.updateWarehouseStore(warehouseStore));
    }

    /**
     * 删除仓库店铺关联信息
     */
    @PreAuthorize("@ss.hasPermi('system:warehouse_store:remove')")
    @Log(title = "仓库店铺关联信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warehouseStoreIds}")
    public AjaxResult remove(@PathVariable Long[] warehouseStoreIds)
    {
        return toAjax(warehouseStoreService.deleteWarehouseStoreByWarehouseStoreIds(warehouseStoreIds));
    }
}
